package org.example.examfx02.entity;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

@JsonTypeInfo(
        use = JsonTypeInfo.Id.NAME,
        include = JsonTypeInfo.As.PROPERTY,
        property = "type" // 根据type字段判断具体类型
)
@JsonSubTypes({
        @JsonSubTypes.Type(value = CourseRequire.class, name = "0"), // type=0对应公共课程
        @JsonSubTypes.Type(value = CourseChoose.class, name = "1")  // type=1对应专业课程
})
public class Course {
    protected String id;
    protected String name;
    protected Integer chooseNum;
    protected String teacherId;
    // 课程类型 0必修  1选修
    protected Integer type;
    public Course(String id,String name,int chooseNum,String teacherId){
        this.id = id;
        this.name = name;
        this.chooseNum = chooseNum;
        this.teacherId = teacherId;
    }
    public Course(){
    }
    public void show(){
        System.out.print(id +" " + name);
        if(type == 0){
            System.out.println(" 必修");
        }else if(type == 1){
            System.out.println(" 选修");
        }else{
            System.out.println(" 其他");
        }
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getType() {
        return type;
    }
    public void setType(int type) {
        this.type = type;
    }
    public int getChooseNum() {
        return chooseNum;
    }
    public void setChooseNum(int choose_num) {
        this.chooseNum = choose_num;
    }
    public String getTeacherId() {
        return teacherId;
    }
    public void setTeacherId(String teacherId) {
        this.teacherId = teacherId;
    }
}


